package com.puris.servlet.admin;

import com.puris.service.admin.Service;
import com.puris.service.admin.ServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

/**
 * @author Sonata
 * @data 2021/11/26 20:08
 */
public class StudentServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServiceImpl service = new ServiceImpl();
        StringBuffer student = null;
        try {
            student = service.selectStudent();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }

        req.setAttribute("student", student);
        req.getRequestDispatcher("jsp/admin/student.jsp").forward(req, resp);
    }
}
